package com.mashibing.juc.c_025;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;

/**
 * 容量为0，多用于任务调度
 */
public class T08_SynchronusQueue {

    public static void main(String[] args) throws InterruptedException{
        BlockingQueue<String> strs = new SynchronousQueue<>();
        new Thread(()->{
            try {
                strs.take();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        strs.put("aaa");//阻塞，等待消费者消费
//        strs.put("bbb");
//        strs.add("aaa");
        System.out.println(strs.size());
    }
}
